<template>
  <Modal
    title="详细信息"
    :value="value"
    :mask-closable="true"
    :footer-hide="true"
    @input="$emit('input', $event)"
  >
    <Form
      ref="formLkyStudent"
      :model="formLkyStudent"
      :rules="ruleValidate"
      label-position="right"
      :label-width="80"
    >
     
    </Form>
  </Modal>
</template>
<script>
import { update } from '@/api/lky/lkyStudent'
import { createModelObj, coverProps, coverFormProps } from '@/libs/util'

export default {
  name: 'Edit',
  props: {
    value: {
      type: Boolean,
      default: false
    },
    lkyStudent: {
      type: Object,
      default: null
    }
  },
  data () {
    return {
      formLkyStudent: {
      },
      ruleValidate: {
      }
    }
  },
  methods: {
    handleSubmit (name) {
      this.$refs[name].validate(valid => {
        if (valid) {
          update(
            Object.assign({}, createModelObj(this.formLkyStudent, 'lkyStudent'))
          ).then(res => {
            if (res) {
              this.$emit('updateRow', coverProps(this.lkyStudent, this.formLkyStudent))
              this.$emit('input', false)
              this.handleReset(name)
            }
          })
        } else {
          this.$Message.error('验证失败!')
        }
      })
    },
    handleReset (name) {
      this.$refs[name].resetFields()
    }
  },
  watch: {
    value: function (val, oldVal) {
      this.$refs.formLkyStudent.resetFields()
      coverFormProps(this.formLkyStudent, this.lkyStudent)
    }
  }
}
</script>